<?php


namespace App\Repositories\Game\Lucky;
use App\Models\GameDB\LuckyStrike\RebateSetting as Model;
use App\Traits\Singleton;
use Illuminate\Database\Eloquent\Builder;
use App\Exceptions\BasicException;
class StrikeSettingRepository
{
    use Singleton;
    /**
     * @param bool $fail
     *
     * @return Builder|\Illuminate\Database\Eloquent\Model|object
     * @throws BasicException
     */
    public function setting(bool $fail = false)
    {
        $query = Model::query();
        $model = $query->first();
        if (!$model) {
            throw new BasicException(-1, "游戏配置中");
        }
        if ($fail && !$model->is_open) {
            throw new BasicException(-1, "游戏未开启");
        }
        return $model;
    }

}
